:root {
    --dt-border-color: #d1d8dd;
    --dt-primary-color: rgb(82, 146, 247);
    --dt-light-bg: #f5f7fa;
    --dt-light-red: #FD8B8B;
    --dt-light-yellow: #fffce7;
    --dt-orange: rgb(255, 160, 10);
    --dt-text-color: #000000;
    --dt-text-light: #dfe2e5;
    --dt-spacer-1: 0.25rem;
    --dt-spacer-2: 0.5rem;
    --dt-spacer-3: 1rem;
    --dt-border-radius: 3px;
    --dt-cell-bg: #fff;
    --dt-focus-border-width: 2px;
    --dt-selection-highlight-color: var(--dt-light-yellow);
    --dt-toast-message-border: none;
    --dt-header-cell-bg: var(--dt-cell-bg);
}

.datatable {
    *, *::after, *::before {
        box-sizing: border-box;
    }
}

.datatable {
    position: relative;
    overflow: hidden;
}

.dt-scrollable {
    height: 40vw;
    overflow: auto;
    border-top: 2px solid var(--dt-border-color);

    &--highlight-all {
        background-color: var(--dt-selection-highlight-color);
    }

    &__no-data {
        text-align: center;
        padding: var(--dt-spacer-3);
        border-left: 1px solid var(--dt-border-color);
        border-right: 1px solid var(--dt-border-color);
    }
}

.dt-row {
    display: flex;

    &--highlight .dt-cell {
        background-color: var(--dt-selection-highlight-color);
    }

    &--unhighlight .dt-cell {
        background-color: var(--dt-cell-bg);
    }

    &--hide {
        display: none;
    }

    &:last-child:not(.dt-row-filter) {
        border-bottom: 1px solid var(--dt-border-color);
    }
}

.dt-cell {
    border: 1px solid var(--dt-border-color);
    border-bottom: none;
    border-right: none;
    position: relative;
    outline: none;
    padding: 0;
    background-color: var(--dt-cell-bg);
    color: var(--dt-text-color);
    /*
     Fix for firefox and Edge
     https://stackoverflow.com/a/16337203
     firefox paints td background over border
    */
    background-clip: padding-box;
    user-select: none;

    &__content {
        padding: var(--dt-spacer-2);
        border: var(--dt-focus-border-width) solid transparent;
        height: 100%;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }

    &__edit {
        display: none;
        padding: var(--dt-spacer-2);
        background-color: var(--dt-cell-bg);
        border: var(--dt-focus-border-width) solid var(--dt-orange);
        z-index: 1;
        height: 100%;
    }

    &__resize-handle {
        opacity: 0;
        position: absolute;
        right: -3px;
        top: 0;
        width: 5px;
        height: 100%;
        cursor: col-resize;
        z-index: 1;
    }

    &--editing &__content {
        display: none;
    }

    &--editing &__edit {
        display: block;
    }

    &--focus &__content {
        border-color: var(--dt-primary-color);
    }

    &--highlight {
        background-color: var(--dt-light-bg);
    }

    &--dragging {
        background-color: var(--dt-light-bg);
    }

    &--header {
        background-color: var(--dt-header-cell-bg);
    }

    &--header:last-child {
        border-right: 1px solid var(--dt-border-color);
    }

    &--header &__content {
        padding-right: var(--dt-spacer-3);
        font-weight: bold;
    }

    &--header:hover .dt-dropdown__toggle {
        opacity: 1;
    }

    &--tree-close {
        .icon-open {
            display: none;
        }

        .icon-close {
            display: flex;
        }
    }

    &:last-child {
        border-right: 1px solid var(--dt-border-color);
    }
}

.datatable[dir=rtl] .dt-cell__resize-handle {
    right: unset;
    left: -3px;
}

.icon-open, .icon-close {
    width: 16px;
    height: 16px;
}

.icon-open {
    display: flex;
}

.icon-close {
    display: none;
}

.dt-dropdown {
    position: absolute;
    right: 10px;
    display: inline-flex;
    vertical-align: top;
    text-align: left;
    font-weight: normal;
    cursor: pointer;

    &__toggle {
        opacity: 0;
        background-color: var(--dt-header-cell-bg);
    }

    &__list {
        position: fixed;
        min-width: 8rem;
        z-index: 1;
        cursor: pointer;
        background-color: var(--dt-cell-bg);
        border-radius: var(--dt-border-radius);
        padding: var(--dt-spacer-2) 0;
        box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);
    }

    &__list-item {
        padding: var(--dt-spacer-2) var(--dt-spacer-3);

        &:hover {
            background-color: var(--dt-light-bg);
        }
    }

    &--active &__list {
        display: block;
    }
}

.dt-tree-node {
    display: flex;
    align-items: center;
    position: relative;

    &__toggle {
        display: inline-block;
        cursor: pointer;
        margin-right: 0.2rem;
    }
}

.dt-toast {
    position: absolute;
    bottom: var(--dt-spacer-3);
    left: 50%;
    transform: translateX(-50%);

    &__message {
        display: inline-block;
        background-color: rgba(0, 0, 0, 0.8);
        color: var(--dt-text-light);
        border-radius: var(--dt-border-radius);
        padding: var(--dt-spacer-2) var(--dt-spacer-3);
        border: var(--dt-toast-message-border);
    }
}

.dt-input {
    outline: none;
    width: 100%;
    border: none;
    overflow: visible;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background-color: inherit;
    color: inherit;
    margin: 0;
    padding: 0;
}

.dt-freeze {
    display: flex;
    justify-content: center;
    align-content: center;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: var(--dt-light-bg);
    opacity: 0.5;
    font-size: 2em;

    &__message {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
    }
}

.dt-paste-target {
    position: fixed;
    left: -999em;
}

body.dt-resize {
    cursor: col-resize;
}
